import { reqCategoryList, reqGetBannerList, reqFloorList } from '@/api/index'//三级联动分类数据API
//home模块的仓库
const state = {
    //home仓库中存储三级菜单的数据
    categoryList: [],
    //轮播图的数据
    bannerList: [],
    //floor组件的数据
    floorList: []
}
const mutations = {
    CATEGORYLIST(state, categoryList) {
        state.categoryList = categoryList
    },
    GETBANNERLIST(state, bannerList) {
        state.bannerList = bannerList;
    },
    GETFLOORLIST(state, floorList) {
        state.floorList = floorList;
    }
}
const actions = {
    async categoryList({ commit }) {
        let result = await reqCategoryList()
        if (result.code == 200) {
            commit('CATEGORYLIST', result.data)
        }
    },
    async getBannerList({ commit }) {//获取轮播图数据
        let result = await reqGetBannerList();
        console.log(result);
        if (result.data.code == 200) {
            commit("GETBANNERLIST", result.data);
        }
    },
    //获取floor数据
    async getFloorList({ commit }) {
        let result = await reqFloorList();
        if (result.data.code == 200) {
            //提交mutation
            commit("GETFLOORLIST", result.data);
        }
    },
}
const getters={}
export default {
    state,
    mutations,
    actions,
    getters
}
